
#region Imports

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Justa.Messaging.Routing
{
    /// <summary>
    /// 
    /// </summary>
    /// 
    /// <typeparam name="T"></typeparam>
    /// 
    /// <param name="message"></param>
    /// 
    /// <returns></returns>
    /// 
    public delegate string[] RoutingPredicate<T>(T message);

    /// <summary>
    /// 
    /// </summary>
    /// 
    public class RoutingRule<T>
    {
        /// <summary>
        /// 
        /// </summary>
        /// 
        private RoutingPredicate<T> routingPredicate;

        /// <summary>
        /// 
        /// </summary>
        /// 
        private string[] defaultDestinations;

        /// <summary>
        /// 
        /// </summary>
        /// 
        private string[] targetDestinations;

        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="routingPredicate"></param>
        /// 
        public RoutingRule(RoutingPredicate<T> routingPredicate)
        {
            Guard.CheckForNull(routingPredicate);
            this.routingPredicate = routingPredicate;
        }

        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <returns></returns>
        /// 
        public string[] Invoke(T message)
        {
            return routingPredicate(message);
        }
    }
}
